package com.summer.test.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.springframework.context.annotation.Scope;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.summer.core.annotations.Logger;
import com.summer.core.annotations.ScopeType;
import com.summer.core.controller.EntityQuery;
import com.summer.test.model.SystemLoanType;


@Component
@Scope(ScopeType.VIEW)
public class SystemLoanTypeList extends EntityQuery<SystemLoanType> {
	
	
	@Resource
	HibernateTemplate ht;
	
	private List<SystemLoanType> listInUse;
	
	public List<SystemLoanType> getListInUse() {
		if (listInUse == null) {
			initListInUse();
		}
		return listInUse;
	}
	@SuppressWarnings("unchecked")
	public void initListInUse()
	{
		try {
			listInUse = getHt().find("select distinct slt from SystemLoanType slt where slt.status='1'");
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e);
		}
	}
	@Logger
	private static Log log;
	
	private String COUNT_HQL = "select count(slt) from SystemLoanType slt";
	private String HQL = "select distinct slt from SystemLoanType slt order by slt.id desc ";
	public SystemLoanTypeList() {
		setCountHql(COUNT_HQL);
		setHql(HQL);
	}
//	public List<SystemLoanType> listInUse()
//	{
//		return getHt().find("select distinct slt from SystemLoanType slt where slt.status='1'");
//	}
//	
	

}
